package com.minimoment.model.action;

import com.minimoment.base.BaseAction;
import com.minimoment.model.domain.Screenings;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * Created by etund on 2014/11/10.
 */
@Controller
@Scope("prototype")
public class ScreeningsAction extends BaseAction<Screenings> {
    private String movieId;
    private String theaterId;
    private String result;
    private JSONArray resultTree;

    public String getScreeningsByTheId() throws Exception{
        if(movieId!=null&&theaterId!=null&&!"".equals(movieId.trim())&&!"".equals(theaterId.trim())){
            this.screeningses = this.screeningsService.getByTMId(Long.parseLong(movieId),Long.parseLong(theaterId));
            JsonConfig jsonConfig = new JsonConfig();
            jsonConfig.setExcludes(new String[]{"screeningsItems","histories"});
            resultTree = JSONArray.fromObject(screeningses,jsonConfig);
            result = resultTree.toString();
        }
        return "getScreeningsByTheId";
    }

    public JSONArray getResultTree() {
        return resultTree;
    }

    public void setResultTree(JSONArray resultTree) {
        this.resultTree = resultTree;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getMovieId() {
        return movieId;
    }

    public void setMovieId(String movieId) {
        this.movieId = movieId;
    }

    public String getTheaterId() {
        return theaterId;
    }

    public void setTheaterId(String theaterId) {
        this.theaterId = theaterId;
    }
}
